This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.
Update all callers.
{
GtkWidget *gridview, *sw;
GtkListItemFactory *factory;
- GListModel *model;
GtkNoSelection *selection;
/* This is the normal window setup code every demo does */
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
- model = create_clocks_model ();
- selection = gtk_no_selection_new (model);
+ selection = gtk_no_selection_new (create_clocks_model ());
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
g_object_unref (selection);
- g_object_unref (model);
}
if (!gtk_widget_get_visible (window))
no_selection = G_LIST_MODEL (gtk_no_selection_new (selection_filter));
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
- g_object_unref (selection_filter);
g_object_unref (no_selection);
selection_info_toggle = gtk_toggle_button_new ();
GtkSortListModel *sort_model;
GtkFilterListModel *filter_model;
GtkFilter *filter;
- GtkNoSelection *selection_model;
char **keys;
guint i;
g_set_object (¤t_filter, filter);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
- selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
- g_object_unref (filter_model);
-
- g_value_take_object (to_value, selection_model);
+ g_value_take_object (to_value, gtk_no_selection_new (G_LIST_MODEL (filter_model)));
return TRUE;
}
create_weather_view (void)
{
GtkWidget *listview;
- GListModel *model, *selection;
+ GListModel *selection;
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
listview = gtk_list_view_new_with_factory (factory);
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
- model = create_weather_model ();
- selection = G_LIST_MODEL (gtk_no_selection_new (model));
+ selection = G_LIST_MODEL (gtk_no_selection_new (create_weather_model ()));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
- g_object_unref (model);
return listview;
}
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
update_title_cb (filter_model);
- g_object_unref (filter_model);
}
if (!gtk_widget_get_visible (window))
/**
* gtk_no_selection_new:
- * @model: (transfer none): the #GListModel to manage
+ * @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
GtkNoSelection *
gtk_no_selection_new (GListModel *model)
{
+ GtkNoSelection *self;
+
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
- return g_object_new (GTK_TYPE_NO_SELECTION,
+ self = g_object_new (GTK_TYPE_NO_SELECTION,
"model", model,
NULL);
+
+ /* consume the reference */
+ g_clear_object (&model);
+
+ return self;
}
/**
* @self: a #GtkNoSelection
* @model: (allow-none): A #GListModel to wrap
*
- * Sets the model that @self should wrap. If @model is %NULL, this
- * model will be empty.
+ * Sets the model that @self should wrap.
+ * If @model is %NULL, this model will be empty.
**/
void
gtk_no_selection_set_model (GtkNoSelection *self,
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list)))));
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->list), model);
- g_object_unref (sorted);
g_object_unref (model);
}
g_object_set (page, "visible", TRUE, NULL);
sl->object = G_LIST_MODEL (object);
- selection = gtk_no_selection_new (sl->object);
+ selection = gtk_no_selection_new (g_object_ref (sl->object));
gtk_column_view_set_model (sl->view, G_LIST_MODEL (selection));
g_object_unref (selection);
}
gtk_widget_show (GTK_WIDGET (pl));
g_object_unref (list);
- g_object_unref (sorted);
return TRUE;
}